package com.youka.bussiness.common.base;


import com.youka.bussiness.common.bean.RestResp;
import lombok.extern.slf4j.Slf4j;

/**
 * @author cai
 */
@Slf4j
public abstract class BaseController {

    /**
     * 返回成功
     */
    public RestResp success() {
        return RestResp.success();
    }

    public RestResp success(Object object) {
        return RestResp.success(object);
    }

    public RestResp success(String key, Object object) {
        return RestResp.success().append(key, object);
    }

    /**
     * 返回失败消息
     */
    public RestResp error() {
        return RestResp.error();
    }

    public RestResp error(String message) {
        return RestResp.error(message);
    }

    public RestResp result(boolean result) {
        return result ? success() : error();
    }

    public RestResp result(boolean result, String message) {
        return result ? success() : error(message);
    }

}
